<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)" prop="merId">
        <el-input
          v-model="queryParams.merId"
          placeholder="请输入商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品名称" prop="storeName">
        <el-input
          v-model="queryParams.storeName"
          placeholder="请输入商品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品简介" prop="storeInfo">
        <el-input
          v-model="queryParams.storeInfo"
          placeholder="请输入商品简介"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="关键字" prop="keyword">
        <el-input
          v-model="queryParams.keyword"
          placeholder="请输入关键字"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品条码" prop="barCode">
        <el-input
          v-model="queryParams.barCode"
          placeholder="请输入商品条码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分类id" prop="cateId">
        <el-input
          v-model="queryParams.cateId"
          placeholder="请输入分类id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品价格" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入商品价格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="会员价格" prop="vipPrice">
        <el-input
          v-model="queryParams.vipPrice"
          placeholder="请输入会员价格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="市场价" prop="otPrice">
        <el-input
          v-model="queryParams.otPrice"
          placeholder="请输入市场价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="邮费" prop="postage">
        <el-input
          v-model="queryParams.postage"
          placeholder="请输入邮费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位名" prop="unitName">
        <el-input
          v-model="queryParams.unitName"
          placeholder="请输入单位名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="排序" prop="sort">
        <el-input
          v-model="queryParams.sort"
          placeholder="请输入排序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销量" prop="sales">
        <el-input
          v-model="queryParams.sales"
          placeholder="请输入销量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库存" prop="stock">
        <el-input
          v-model="queryParams.stock"
          placeholder="请输入库存"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="isShow">
        <el-select v-model="queryParams.isShow" placeholder="请选择状态" clearable>
          <el-option
            v-for="dict in dict.type.product_is_show"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否热卖" prop="isHot">
        <el-select v-model="queryParams.isHot" placeholder="请选择是否热卖" clearable>
          <el-option
            v-for="dict in dict.type.product_is_hot"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否优惠" prop="isBenefit">
        <el-select v-model="queryParams.isBenefit" placeholder="请选择是否优惠" clearable>
          <el-option
            v-for="dict in dict.type.product_is_benefit"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否精品" prop="isBest">
        <el-select v-model="queryParams.isBest" placeholder="请选择是否精品" clearable>
          <el-option
            v-for="dict in dict.type.product_is_best"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否新品" prop="isNew">
        <el-select v-model="queryParams.isNew" placeholder="请选择是否新品" clearable>
          <el-option
            v-for="dict in dict.type.product_is_new"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="addTime">
        <el-input
          v-model="queryParams.addTime"
          placeholder="请输入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否包邮" prop="isPostage">
        <el-select v-model="queryParams.isPostage" placeholder="请选择是否包邮" clearable>
          <el-option
            v-for="dict in dict.type.product_is_postage"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="商户是否代理 0不可代理1可代理" prop="merUse">
        <el-select v-model="queryParams.merUse" placeholder="请选择商户是否代理 0不可代理1可代理" clearable>
          <el-option
            v-for="dict in dict.type.product_mer_use"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="获得积分" prop="giveIntegral">
        <el-input
          v-model="queryParams.giveIntegral"
          placeholder="请输入获得积分"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成本价" prop="cost">
        <el-input
          v-model="queryParams.cost"
          placeholder="请输入成本价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="秒杀状态 0 未开启 1已开启" prop="isSeckill">
        <el-select v-model="queryParams.isSeckill" placeholder="请选择秒杀状态 0 未开启 1已开启" clearable>
          <el-option
            v-for="dict in dict.type.product_is_seckill"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="砍价状态 0未开启 1开启" prop="isBargain">
        <el-select v-model="queryParams.isBargain" placeholder="请选择砍价状态 0未开启 1开启" clearable>
          <el-option
            v-for="dict in dict.type.product_is_bargain"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否优品推荐" prop="isGood">
        <el-select v-model="queryParams.isGood" placeholder="请选择是否优品推荐" clearable>
          <el-option
            v-for="dict in dict.type.product_is_good"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否单独分佣" prop="isSub">
        <el-select v-model="queryParams.isSub" placeholder="请选择是否单独分佣" clearable>
          <el-option
            v-for="dict in dict.type.product_is_sub"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="虚拟销量" prop="ficti">
        <el-input
          v-model="queryParams.ficti"
          placeholder="请输入虚拟销量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="浏览量" prop="browse">
        <el-input
          v-model="queryParams.browse"
          placeholder="请输入浏览量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品二维码地址(用户小程序海报)" prop="codePath">
        <el-input
          v-model="queryParams.codePath"
          placeholder="请输入商品二维码地址(用户小程序海报)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="淘宝京东1688类型" prop="soureLink">
        <el-input
          v-model="queryParams.soureLink"
          placeholder="请输入淘宝京东1688类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运费模板ID" prop="tempId">
        <el-input
          v-model="queryParams.tempId"
          placeholder="请输入运费模板ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="活动显示排序0=默认, 1=秒杀，2=砍价，3=拼团" prop="activity">
        <el-input
          v-model="queryParams.activity"
          placeholder="请输入活动显示排序0=默认, 1=秒杀，2=砍价，3=拼团"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否回收站" prop="isRecycle">
        <el-select v-model="queryParams.isRecycle" placeholder="请选择是否回收站" clearable>
          <el-option
            v-for="dict in dict.type.product_is_recycle"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否为积分商品" prop="isPointProduct">
        <el-select v-model="queryParams.isPointProduct" placeholder="请选择是否为积分商品" clearable>
          <el-option
            v-for="dict in dict.type.product_is_point_product"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="兑换所需积分" prop="pointsRequired">
        <el-input
          v-model="queryParams.pointsRequired"
          placeholder="请输入兑换所需积分"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否为定制 0=否，1=是" prop="isCustomized">
        <el-select v-model="queryParams.isCustomized" placeholder="请选择是否为定制 0=否，1=是" clearable>
          <el-option
            v-for="dict in dict.type.product_is_customized"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['product:info:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['product:info:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['product:info:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['product:info:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="商品id" align="center" prop="id" />
      <el-table-column label="商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)" align="center" prop="merId" />
      <el-table-column label="商品图片" align="center" prop="image" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.image" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="轮播图" align="center" prop="sliderImage" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.sliderImage" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="商品名称" align="center" prop="storeName" />
      <el-table-column label="商品简介" align="center" prop="storeInfo" />
      <el-table-column label="关键字" align="center" prop="keyword" />
      <el-table-column label="商品条码" align="center" prop="barCode" />
      <el-table-column label="分类id" align="center" prop="cateId" />
      <el-table-column label="商品价格" align="center" prop="price" />
      <el-table-column label="会员价格" align="center" prop="vipPrice" />
      <el-table-column label="市场价" align="center" prop="otPrice" />
      <el-table-column label="邮费" align="center" prop="postage" />
      <el-table-column label="单位名" align="center" prop="unitName" />
      <el-table-column label="排序" align="center" prop="sort" />
      <el-table-column label="销量" align="center" prop="sales" />
      <el-table-column label="库存" align="center" prop="stock" />
      <el-table-column label="状态" align="center" prop="isShow">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_show" :value="scope.row.isShow"/>
        </template>
      </el-table-column>
      <el-table-column label="是否热卖" align="center" prop="isHot">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_hot" :value="scope.row.isHot"/>
        </template>
      </el-table-column>
      <el-table-column label="是否优惠" align="center" prop="isBenefit">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_benefit" :value="scope.row.isBenefit"/>
        </template>
      </el-table-column>
      <el-table-column label="是否精品" align="center" prop="isBest">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_best" :value="scope.row.isBest"/>
        </template>
      </el-table-column>
      <el-table-column label="是否新品" align="center" prop="isNew">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_new" :value="scope.row.isNew"/>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="addTime" />
      <el-table-column label="是否包邮" align="center" prop="isPostage">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_postage" :value="scope.row.isPostage"/>
        </template>
      </el-table-column>
      <el-table-column label="是否删除" align="center" prop="isDel" />
      <el-table-column label="商户是否代理 0不可代理1可代理" align="center" prop="merUse">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_mer_use" :value="scope.row.merUse"/>
        </template>
      </el-table-column>
      <el-table-column label="获得积分" align="center" prop="giveIntegral" />
      <el-table-column label="成本价" align="center" prop="cost" />
      <el-table-column label="秒杀状态 0 未开启 1已开启" align="center" prop="isSeckill">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_seckill" :value="scope.row.isSeckill"/>
        </template>
      </el-table-column>
      <el-table-column label="砍价状态 0未开启 1开启" align="center" prop="isBargain">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_bargain" :value="scope.row.isBargain"/>
        </template>
      </el-table-column>
      <el-table-column label="是否优品推荐" align="center" prop="isGood">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_good" :value="scope.row.isGood"/>
        </template>
      </el-table-column>
      <el-table-column label="是否单独分佣" align="center" prop="isSub">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_sub" :value="scope.row.isSub"/>
        </template>
      </el-table-column>
      <el-table-column label="虚拟销量" align="center" prop="ficti" />
      <el-table-column label="浏览量" align="center" prop="browse" />
      <el-table-column label="商品二维码地址(用户小程序海报)" align="center" prop="codePath" />
      <el-table-column label="淘宝京东1688类型" align="center" prop="soureLink" />
      <el-table-column label="主图视频链接" align="center" prop="videoLink" />
      <el-table-column label="运费模板ID" align="center" prop="tempId" />
      <el-table-column label="活动显示排序0=默认, 1=秒杀，2=砍价，3=拼团" align="center" prop="activity" />
      <el-table-column label="展示图" align="center" prop="flatPattern" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.flatPattern" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="是否回收站" align="center" prop="isRecycle">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_recycle" :value="scope.row.isRecycle"/>
        </template>
      </el-table-column>
      <el-table-column label="是否为积分商品" align="center" prop="isPointProduct">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_point_product" :value="scope.row.isPointProduct"/>
        </template>
      </el-table-column>
      <el-table-column label="兑换所需积分" align="center" prop="pointsRequired" />
      <el-table-column label="是否为定制 0=否，1=是" align="center" prop="isCustomized">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_is_customized" :value="scope.row.isCustomized"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['product:info:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['product:info:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改商品对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)" prop="merId">
          <el-input v-model="form.merId" placeholder="请输入商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)" />
        </el-form-item>
        <el-form-item label="商品图片" prop="image">
          <image-upload v-model="form.image"/>
        </el-form-item>
        <el-form-item label="轮播图" prop="sliderImage">
          <image-upload v-model="form.sliderImage"/>
        </el-form-item>
        <el-form-item label="商品名称" prop="storeName">
          <el-input v-model="form.storeName" placeholder="请输入商品名称" />
        </el-form-item>
        <el-form-item label="商品简介" prop="storeInfo">
          <el-input v-model="form.storeInfo" placeholder="请输入商品简介" />
        </el-form-item>
        <el-form-item label="关键字" prop="keyword">
          <el-input v-model="form.keyword" placeholder="请输入关键字" />
        </el-form-item>
        <el-form-item label="商品条码" prop="barCode">
          <el-input v-model="form.barCode" placeholder="请输入商品条码" />
        </el-form-item>
        <el-form-item label="分类id" prop="cateId">
          <el-input v-model="form.cateId" placeholder="请输入分类id" />
        </el-form-item>
        <el-form-item label="商品价格" prop="price">
          <el-input v-model="form.price" placeholder="请输入商品价格" />
        </el-form-item>
        <el-form-item label="会员价格" prop="vipPrice">
          <el-input v-model="form.vipPrice" placeholder="请输入会员价格" />
        </el-form-item>
        <el-form-item label="市场价" prop="otPrice">
          <el-input v-model="form.otPrice" placeholder="请输入市场价" />
        </el-form-item>
        <el-form-item label="邮费" prop="postage">
          <el-input v-model="form.postage" placeholder="请输入邮费" />
        </el-form-item>
        <el-form-item label="单位名" prop="unitName">
          <el-input v-model="form.unitName" placeholder="请输入单位名" />
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <el-input v-model="form.sort" placeholder="请输入排序" />
        </el-form-item>
        <el-form-item label="销量" prop="sales">
          <el-input v-model="form.sales" placeholder="请输入销量" />
        </el-form-item>
        <el-form-item label="库存" prop="stock">
          <el-input v-model="form.stock" placeholder="请输入库存" />
        </el-form-item>
        <el-form-item label="状态" prop="isShow">
          <el-select v-model="form.isShow" placeholder="请选择状态">
            <el-option
              v-for="dict in dict.type.product_is_show"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否热卖" prop="isHot">
          <el-select v-model="form.isHot" placeholder="请选择是否热卖">
            <el-option
              v-for="dict in dict.type.product_is_hot"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否优惠" prop="isBenefit">
          <el-select v-model="form.isBenefit" placeholder="请选择是否优惠">
            <el-option
              v-for="dict in dict.type.product_is_benefit"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否精品" prop="isBest">
          <el-select v-model="form.isBest" placeholder="请选择是否精品">
            <el-option
              v-for="dict in dict.type.product_is_best"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否新品" prop="isNew">
          <el-select v-model="form.isNew" placeholder="请选择是否新品">
            <el-option
              v-for="dict in dict.type.product_is_new"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="addTime">
          <el-input v-model="form.addTime" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="是否包邮" prop="isPostage">
          <el-select v-model="form.isPostage" placeholder="请选择是否包邮">
            <el-option
              v-for="dict in dict.type.product_is_postage"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="商户是否代理 0不可代理1可代理" prop="merUse">
          <el-select v-model="form.merUse" placeholder="请选择商户是否代理 0不可代理1可代理">
            <el-option
              v-for="dict in dict.type.product_mer_use"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="获得积分" prop="giveIntegral">
          <el-input v-model="form.giveIntegral" placeholder="请输入获得积分" />
        </el-form-item>
        <el-form-item label="成本价" prop="cost">
          <el-input v-model="form.cost" placeholder="请输入成本价" />
        </el-form-item>
        <el-form-item label="秒杀状态 0 未开启 1已开启" prop="isSeckill">
          <el-select v-model="form.isSeckill" placeholder="请选择秒杀状态 0 未开启 1已开启">
            <el-option
              v-for="dict in dict.type.product_is_seckill"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="砍价状态 0未开启 1开启" prop="isBargain">
          <el-select v-model="form.isBargain" placeholder="请选择砍价状态 0未开启 1开启">
            <el-option
              v-for="dict in dict.type.product_is_bargain"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否优品推荐" prop="isGood">
          <el-select v-model="form.isGood" placeholder="请选择是否优品推荐">
            <el-option
              v-for="dict in dict.type.product_is_good"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否单独分佣" prop="isSub">
          <el-select v-model="form.isSub" placeholder="请选择是否单独分佣">
            <el-option
              v-for="dict in dict.type.product_is_sub"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="虚拟销量" prop="ficti">
          <el-input v-model="form.ficti" placeholder="请输入虚拟销量" />
        </el-form-item>
        <el-form-item label="浏览量" prop="browse">
          <el-input v-model="form.browse" placeholder="请输入浏览量" />
        </el-form-item>
        <el-form-item label="商品二维码地址(用户小程序海报)" prop="codePath">
          <el-input v-model="form.codePath" placeholder="请输入商品二维码地址(用户小程序海报)" />
        </el-form-item>
        <el-form-item label="淘宝京东1688类型" prop="soureLink">
          <el-input v-model="form.soureLink" placeholder="请输入淘宝京东1688类型" />
        </el-form-item>
        <el-form-item label="主图视频链接" prop="videoLink">
          <file-upload v-model="form.videoLink"/>
        </el-form-item>
        <el-form-item label="运费模板ID" prop="tempId">
          <el-input v-model="form.tempId" placeholder="请输入运费模板ID" />
        </el-form-item>
        <el-form-item label="活动显示排序0=默认, 1=秒杀，2=砍价，3=拼团" prop="activity">
          <el-input v-model="form.activity" placeholder="请输入活动显示排序0=默认, 1=秒杀，2=砍价，3=拼团" />
        </el-form-item>
        <el-form-item label="展示图" prop="flatPattern">
          <image-upload v-model="form.flatPattern"/>
        </el-form-item>
        <el-form-item label="是否回收站" prop="isRecycle">
          <el-radio-group v-model="form.isRecycle">
            <el-radio
              v-for="dict in dict.type.product_is_recycle"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否为积分商品" prop="isPointProduct">
          <el-select v-model="form.isPointProduct" placeholder="请选择是否为积分商品">
            <el-option
              v-for="dict in dict.type.product_is_point_product"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="兑换所需积分" prop="pointsRequired">
          <el-input v-model="form.pointsRequired" placeholder="请输入兑换所需积分" />
        </el-form-item>
        <el-form-item label="是否为定制 0=否，1=是" prop="isCustomized">
          <el-select v-model="form.isCustomized" placeholder="请选择是否为定制 0=否，1=是">
            <el-option
              v-for="dict in dict.type.product_is_customized"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/product/info";

export default {
  name: "Info",
  dicts: ['product_mer_use', 'product_is_best', 'product_is_new', 'product_is_seckill', 'product_is_recycle', 'product_is_customized', 'product_is_sub', 'product_is_show', 'product_is_point_product', 'product_is_bargain', 'product_is_hot', 'product_is_benefit', 'product_is_postage', 'product_is_good'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商品表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        merId: null,
        image: null,
        sliderImage: null,
        storeName: null,
        storeInfo: null,
        keyword: null,
        barCode: null,
        cateId: null,
        price: null,
        vipPrice: null,
        otPrice: null,
        postage: null,
        unitName: null,
        sort: null,
        sales: null,
        stock: null,
        isShow: null,
        isHot: null,
        isBenefit: null,
        isBest: null,
        isNew: null,
        addTime: null,
        isPostage: null,
        isDel: null,
        merUse: null,
        giveIntegral: null,
        cost: null,
        isSeckill: null,
        isBargain: null,
        isGood: null,
        isSub: null,
        ficti: null,
        browse: null,
        codePath: null,
        soureLink: null,
        videoLink: null,
        tempId: null,
        activity: null,
        flatPattern: null,
        isRecycle: null,
        isPointProduct: null,
        pointsRequired: null,
        isCustomized: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询商品列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        merId: null,
        image: null,
        sliderImage: null,
        storeName: null,
        storeInfo: null,
        keyword: null,
        barCode: null,
        cateId: null,
        price: null,
        vipPrice: null,
        otPrice: null,
        postage: null,
        unitName: null,
        sort: null,
        sales: null,
        stock: null,
        isShow: null,
        isHot: null,
        isBenefit: null,
        isBest: null,
        isNew: null,
        addTime: null,
        isPostage: null,
        isDel: null,
        merUse: null,
        giveIntegral: null,
        cost: null,
        isSeckill: null,
        isBargain: null,
        isGood: null,
        isSub: null,
        ficti: null,
        browse: null,
        codePath: null,
        soureLink: null,
        videoLink: null,
        tempId: null,
        activity: null,
        flatPattern: null,
        isRecycle: null,
        isPointProduct: null,
        pointsRequired: null,
        isCustomized: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加商品";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改商品";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除商品编号为"' + ids + '"的数据项？').then(function() {
        return delInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('product/info/export', {
        ...this.queryParams
      }, `info_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
